<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合同管理</title>
<% request.setAttribute("menu", 1); %>
<%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css"/>
<link rel="stylesheet" href="<%=basePath%>css/system.css" media="all"/>
<link rel="stylesheet" href="<%=basePath%>css/tab.css" media="all" />
</head>
<body> 
  <c:if test="${info.contracttype==2}">
  		<div id="TM-layui-hetong" >
	<div class="TM-he-tong admin-entering">
		<form class="layui-form TM-entering-form" action="" id="enterform" novalidate="novalidate">
        <div class="form-left">
            <div class="layui-form-item">
                <label class="layui-form-label">单位名称 : </label>
                <div class="layui-input-block">${info.customerInfo.cname}</div>
            </div>
              <div class="layui-form-item">
                <label class="layui-form-label">服务费用 : </label>
                <div class="layui-input-block">	              	                
	              <fmt:formatNumber value="${info.totalamount}" pattern="#,#00"/>元           
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">其它费用 : </label>
                <div class="layui-input-block"><fmt:formatNumber value="${info.servicecharge}" pattern="#,#00"/>元</div>       
		               
            </div>
           
            <div class="layui-form-item layui-form-text">
	            <label class="layui-form-label">合同备注 : </label>
	            <div class="layui-input-block">${info.remark}</div>  
        	</div>
        	<div class="layui-form-item">
        		<label class="layui-form-label">企业合同文件 :</label>
        		<div class="layui-input-block">
        			<c:forEach var="fileobj" items="${info.fileList}" varStatus="f1">
        				<span data="${fileobj.fileid}" uiddata="${info.customerInfo.uid}">
    						<a style="margin: 0 10px 0 0; text-decoration: underline; color: #2591D0;" 
        					href="/file/${fileobj.fileid}" title="${fileobj.remark}">文件${f1.index+1}</a>
    						<c:if test="${info.customerInfo.uid == sessionScope.user.id}">
    							<a class="deletfile" href="#" style="margin:0 10px 0 -10px; text-decoration:none; color:red;">
    								<i class="layui-icon" style="font-size: 14px;">&#x1006;</i>
    							</a>
    						</c:if>
	            		</span>
        			</c:forEach>
        		</div>
        	</div>             
        </div>
        <div class="form-right">
           <div class="layui-form-item">
                <label class="layui-form-label">合同签订时间 : </label>
                <div class="layui-input-block">${info.signingtime.substring(0,10)}</div>
            </div>
            <div class="layui-form-item warehouse">
                <label class="layui-form-label">合同类型: </label>
                <div class="layui-input-block">
					<dic:cf type="1" name="contract_type" value="${info.contracttype}"/>
				</div>
            </div> 
       <%--      <div class="layui-form-item" >
            	<label class="layui-form-label">合同签订年限 : </label>
                <div class="layui-input-block">
                	<dic:cf type="1" name="life_type" value="${info.lifetype}"/>
                </div>
            </div>             --%>
        </div>
        <c:set  property="rcjgtitle"  var="rcjgtitle" value="个人客户价格" /><c:set  property="qyjgtitle" var="qyjgtitle" value="企业客户价格" />
          <c:set  property="bzsm"  var="bzsm" value="备注" />
        <div class="layui-form-item TM-hetong-zhengshu">
      		<label class="layui-form-label"><c:if test="${info.contracttype==0}">资质<c:set  property="rcjgtitle"  var="rcjgtitle" value="成本价" /><c:set  property="qyjgtitle" var="qyjgtitle" value="代办价格" /></c:if><c:if test="${info.contracttype==1}">猎证</c:if><c:if test="${info.contracttype==2}">培训<c:set  property="rcjgtitle"  var="rcjgtitle" value="单价" /><c:set  property="qyjgtitle" var="qyjgtitle" value="总价" /><c:set  property="bzsm"  var="bzsm" value="数量（本）" /></c:if> : </label> 
            <div class="layui-input-block">
            	<c:forEach var="obj"  items="${info.sublist}" >
      		       <div class="TM-hetong-block">
		            	<ul class="clefix">
		            		<li>培训内容：${obj.remark}</li>
		            		<c:if test="${obj.isadditional==1}">
		            			 <li>其它费用:<span><fmt:formatNumber value="${obj.totalamount}" pattern="#,#00"/>元</span></li> 
		            		</c:if>
		            		<c:if test="${obj.isadditional==null||obj.isadditional==0}">
		            		 <li>${rcjgtitle}：<span><fmt:formatNumber value="${obj.totalamount}" pattern="#,#00"/>元</span></li>
		            		 <li>${qyjgtitle}：<span><fmt:formatNumber value="${obj.alonemoney}" pattern="#,#00"/>元</span></li>
		            		 <li>${bzsm}：<span>${obj.zsremark}</span></li>
		            		</c:if>
		            		<li><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
		            	</ul>
		            </div>	 
      		    </c:forEach> 
            </div>
     	</div> 
     	<div class="layui-form-item TM-hetong-jilu">
      		<label class="layui-form-label">回款记录: </label>
            <div class="layui-input-block">
            	<c:forEach  items="${info.mlList}"  var="ml">
            		 <div class="TM-hetong-block">
	            		<span class="TM-jilu-date">${ml.updatedate.substring(0,10)}</span>
	            		<c:if test="${ml.approvalstatus==1}">
	            			<!-- 待审批 -->
	            			<span class="TM-icondsp icon-stamp"></span>
	            		</c:if>
	            		<c:if test="${ml.approvalstatus==0}">
	            			<!-- 审批中 -->
	            			<span class="TM-icon icon-stamp"></span>
	            		</c:if>
	            		<c:if test="${ml.approvalstatus==2}">
	            			<!-- 审批通过 -->
	            			<span class="TM-iconytg icon-stamp"></span>
	            		</c:if>
	            		<c:if test="${ml.approvalstatus==3}">
	            			<!-- 驳回 -->
	            			<span class="TM-iconbh icon-stamp"></span>
	            		</c:if>
		            	<ul>
		            		<li>回款金额:${ml.totalamount}元(${ml.transfertype==0?"现金":"转账"})</li>
		            		<li>到帐时间:${ml.arrivaltime.substring(0,10)} </li>
							<li>收款方式:${ml.moneytype==0?"预付款":ml.moneytype==1?"全款":ml.moneytype==2?"中期款":"公示款"}</li>
							<li>收款账户:${ml.bankname}</li>
							<li>打款帐号或打款人:${ml.name}${ml.remark}</li>
							<li>
								<c:if test="${ml.voucher != null && ml.voucher.length() > 0 }">
									回款凭证:
									<c:forEach items="${ml.voucher.split(',')}" var="pzobj" varStatus="p1">
										<a class="showpz" data="${pzobj}">凭证${p1.index+1}</a>
									</c:forEach>
								</c:if>
								<c:if test="${ml.voucher == null || ml.voucher.length() < 1 }">
									回款凭证:暂无凭证
								</c:if>
							<%-- 回款凭证:${ml.voucher.length()} --%>
							</li>
		            	</ul>
	            	</div> 	
            	</c:forEach> 
            </div>
     	</div>         
       <!--  <div class="layui-form-item TM-save-item">
            <div class="layui-input-block">
            	<input type="hidden" value="" id="id" name="id">
            	<input type="hidden" value="1" id="type" name="type">
            	<input type="hidden" value="" id="states" name="states">
                <button class="layui-btn save-btn" lay-submit="" lay-filter="save">预览合同</button>
                <button class="layui-btn save-btn" lay-submit="" lay-filter="save">修改</button>
            </div>
        </div> -->
    </form>
	</div>
</div>
  
  </c:if>

  <c:if test="${info.contracttype==1||info.contracttype==0}">
<div id="TM-layui-hetong" >
	<div class="TM-he-tong admin-entering">
		<form class="layui-form TM-entering-form" action="" id="enterform" novalidate="novalidate">
        <div class="form-left">
            <div class="layui-form-item">
                <label class="layui-form-label">单位名称 : </label>
                <div class="layui-input-block">${info.customerInfo.cname}</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">服务费用 : </label>
                <div class="layui-input-block"><fmt:formatNumber value="${info.servicecharge}" pattern="#,#00"/>元</div>       
		               
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">合同签订时间 : </label>
                <div class="layui-input-block">${info.signingtime.substring(0,10)}</div>
            </div>
            <div class="layui-form-item layui-form-text">
	            <label class="layui-form-label">合同备注 : </label>
	            <div class="layui-input-block">${info.remark}</div>  
        	</div>
        	<div class="layui-form-item">
        		<label class="layui-form-label">企业合同文件 :</label>
        		<div class="layui-input-block">
        			<c:forEach var="fileobj" items="${info.fileList}" varStatus="f1">
        				<span data="${fileobj.fileid}" uiddata="${info.customerInfo.uid}">
    						<a style="margin: 0 10px 0 0; text-decoration: underline; color: #2591D0;" 
        					href="/file/${fileobj.fileid}" title="${fileobj.remark}">文件${f1.index+1}</a>
    						<c:if test="${info.customerInfo.uid == sessionScope.user.id}">
    							<a class="deletfile" href="#" style="margin:0 10px 0 -10px; text-decoration:none; color:red;">
    								<i class="layui-icon" style="font-size: 14px;">&#x1006;</i>
    							</a>
    						</c:if>
	            		</span>
        			</c:forEach>
        		</div>
        	</div>             
        </div>
        <div class="form-right">
            <div class="layui-form-item">
                <label class="layui-form-label">合同金额 : </label>
                <div class="layui-input-block">	              	                
	              <fmt:formatNumber value="${info.totalamount}" pattern="#,#00"/>元           
                </div>
            </div>
            <div class="layui-form-item warehouse">
                <label class="layui-form-label">合同类型: </label>
                <div class="layui-input-block">
					<dic:cf type="1" name="contract_type" value="${info.contracttype}"/>
				</div>
            </div> 
            <div class="layui-form-item">
            	<label class="layui-form-label">合同签订年限 : </label>
                <div class="layui-input-block">
                	<dic:cf type="1" name="life_type" value="${info.lifetype}"/>
                </div>
            </div>            
        </div>
        
          <c:if test="${info.contracttype==1}">
        <c:set  property="rcjgtitle"  var="rcjgtitle" value="人才证书价格" /><c:set  property="qyjgtitle" var="qyjgtitle" value="企业证书价格" />
          <c:set  property="bzsm"  var="bzsm" value="备注" />
        <div class="layui-form-item TM-hetong-zhengshu">
      		<label class="layui-form-label"><c:if test="${info.contracttype==0}">资质<c:set  property="rcjgtitle"  var="rcjgtitle" value="成本价" /><c:set  property="qyjgtitle" var="qyjgtitle" value="代办价格" /></c:if><c:if test="${info.contracttype==1}">猎证</c:if><c:if test="${info.contracttype==2}">培训<c:set  property="rcjgtitle"  var="rcjgtitle" value="单价" /><c:set  property="qyjgtitle" var="qyjgtitle" value="总价" /><c:set  property="bzsm"  var="bzsm" value="数量（本）" /></c:if> : </label> 
            <div class="layui-input-block">
            	<c:forEach var="obj"  items="${info.sublist}" >
      		       <div class="TM-hetong-block">
		            	<ul class="clefix">
		            		<li>${obj.customerInfo.cname}</li>
		            		<c:if test="${obj.isadditional==1}">
		            			 <li>其它费用:<span><fmt:formatNumber value="${obj.totalamount}" pattern="#,#00"/>元</span></li> 
		            		</c:if>
		            		<c:if test="${obj.isadditional==null||obj.isadditional==0}">
		            		 <li>${rcjgtitle}:<span><fmt:formatNumber value="${obj.totalamount}" pattern="#,#00"/>元</span></li>
		            		 <li>${qyjgtitle}:<span><fmt:formatNumber value="${obj.alonemoney}" pattern="#,#00"/>元</span></li>
		            		 <li>${bzsm}:<span>${obj.zsremark}</span></li>
		            		</c:if>
		            		<li>所属人:<span>${obj.createuserName}</span></li>
		            		<li><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
		            		<!-- 只有在上传了人才合同之后，才显示人才合同文件 -->
		            		<li class="hetong-file-name"> 合同文件:
	            				<c:forEach var="fileobj" items="${obj.fileList}" varStatus="f1">
	            					<span data="${fileobj.fileid}" uiddata="${obj.customerInfo.uid}">
	            						<a href="/file/${fileobj.fileid}" title="${fileobj.remark}">
	            							文件${f1.index+1}
	            						</a>
	            						<c:if test="${obj.customerInfo.uid == sessionScope.user.id}">
	            							<a class="deletfile" href="#" style="margin:0 10px 0 -10px; text-decoration:none; color:red;">
	            								<i class="layui-icon" style="font-size: 14px;">&#x1006;</i>
	            							</a>
	            						</c:if>
	            					</span>
	            				</c:forEach>
		            		</li>
		            	</ul>
		            </div>	
      		    </c:forEach> 
            </div>
     	</div> 
        </c:if>
     	<div class="layui-form-item TM-hetong-jilu">
      		<label class="layui-form-label">回款记录: </label>
            <div class="layui-input-block">
            	<c:forEach  items="${info.mlList}"  var="ml">
            		 <div class="TM-hetong-block">
	            		<span class="TM-jilu-date">${ml.updatedate.substring(0,10)}</span>
	            		<c:if test="${ml.approvalstatus==1}">
	            			<!-- 待审批 -->
	            			<span class="TM-icondsp icon-stamp"></span>
	            		</c:if>
	            		<c:if test="${ml.approvalstatus==0}">
	            			<!-- 审批中 -->
	            			<span class="TM-icon icon-stamp"></span>
	            		</c:if>
	            		<c:if test="${ml.approvalstatus==2}">
	            			<!-- 审批通过 -->
	            			<span class="TM-iconytg icon-stamp"></span>
	            		</c:if>
	            		<c:if test="${ml.approvalstatus==3}">
	            			<!-- 驳回 -->
	            			<span class="TM-iconbh icon-stamp"></span>
	            		</c:if>
		            	<ul>
		            		<li>回款金额:${ml.totalamount}元(${ml.transfertype==0?"现金":"转账"})</li>
		            		<li>到帐时间:${ml.arrivaltime.substring(0,10)} </li>
							<li>收款方式:${ml.moneytype==0?"预付款":ml.moneytype==1?"全款":ml.moneytype==2?"中期款":"公示款"}</li>
							<li>收款账户:${ml.bankname}</li>
							<li>打款帐号或打款人:${ml.name}${ml.remark}</li>
							<li>
								<c:if test="${ml.voucher != null && ml.voucher.length() > 0 }">
									回款凭证:
									<c:forEach items="${ml.voucher.split(',')}" var="pzobj" varStatus="p1">
										<a class="showpz" data="${pzobj}">凭证${p1.index+1}</a>
									</c:forEach>
								</c:if>
								<c:if test="${ml.voucher == null || ml.voucher.length() < 1 }">
									回款凭证:暂无凭证
								</c:if>
							<%-- 回款凭证:${ml.voucher.length()} --%>
							</li>
		            	</ul>
	            	</div> 	
            	</c:forEach> 
            </div>
     	</div>         
       <!--  <div class="layui-form-item TM-save-item">
            <div class="layui-input-block">
            	<input type="hidden" value="" id="id" name="id">
            	<input type="hidden" value="1" id="type" name="type">
            	<input type="hidden" value="" id="states" name="states">
                <button class="layui-btn save-btn" lay-submit="" lay-filter="save">预览合同</button>
                <button class="layui-btn save-btn" lay-submit="" lay-filter="save">修改</button>
            </div>
        </div> -->
    </form>
	</div>
</div>
</c:if>
<script type="text/javascript">

layui.use(['laytpl','form','laydate'], function() {
    var $ = layui.jquery,
            layer = layui.layer,
            laytpl = layui.laytpl
    
    var form = layui.form();
    
    //点击删除上传的合同文件
    $(document).on("click",".deletfile",function(){
		//获取文件id
    	var fileid = $(this).parent().attr("data");
		var uid = $(this).parent().attr("uiddata");
		var _this  = $(this);
		
		$.ajax({
			type : "post",
			url : "/customer/deletecontractfile",
			data : {fileid : fileid,uid : uid},
			dataType : "json",
			success : function(data){
				
				if (data == 0) {
					layer.msg("参数错误...删除失败");
				} else {
					layer.msg("文件删除成功");			
					_this.parent().hide();
				}
			}
		});
    	
    });
    
    //点击查看照片
    $(document).on("click",".showpz",function(){
    	var fileid = $(this).attr("data");
    	var html = "/file/"+ fileid;
    	
		layer.photos({
			photos: {
		    	  "title": "", //相册标题
		    	  "id": 1, //相册id
		    	  "start": 0, //初始显示的图片序号，默认0
		    	  "data": [   //相册包含的图片，数组格式
		    	    {
		    	      "alt": "",
		    	      "pid": fileid, //图片id
		    	      "src": html, //原图地址
		    	      "thumb": "" //缩略图地址
		    	    }
		    	  ]
			}
			,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
		}); 
    });

});
	
</script>

 

</body>
</html>